<%@ page import="java.util.*, database.*, java.sql.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <%
            DBCon db = new DBCon();
            String title = "Student Registration - SPMS";
            String control = db.getControlValue("student_reg");
        %>
        <title><%=title%></title>
        
        <%@ include file="../master/head.jsp"%>
<script src='../js/isUserExist.js'></script>      
<script>
            function isCorrect(t)
            {
				inno = document.getElementById('incorrectFields');
                if (t.fn.value == '' )					
				{	inno.innerHTML = 'Invalid First Name';return false;}
				else if ( t.mn.value == '' )
				{	inno.innerHTML = 'Invalid Father Name';return false;}
				else if ( t.ln.value == '' )
				{	inno.innerHTML = 'Invalid Last Name';return false;}
				else if (  parseFloat(t.GPA.value )>5)
				{	inno.innerHTML = 'Invalid GPA (should be less than five).';return false;}
				else if (  parseFloat(t.GPA.value )<0)
				{	inno.innerHTML = 'Invalid GPA (should be greater than zero).';return false;}
				else if ( t.login.value == '' )
				{	inno.innerHTML = 'Invalid Username';return false;}
				else if ( t.pwd.value == '' )
				{	inno.innerHTML = 'Invalid Password';return false;}
				else if ( t.pwd.value != t.rpwd.value)
				{	inno.innerHTML = 'Passwords not matches.';return false;}
				else if ( !isEmail(t.email.value) )
				{	inno.innerHTML = 'Invalid Email';return false;}
				else	
					 {
						  t.GPA.value = parseFloat(t.GPA.value );
					return true;
					 }

            }
            function isEmail(t)
            {
				if (t.indexOf('.') > t.indexOf('@')+1 && t.indexOf('@') > 0)
					 return true;
				  else
					   return false;
              }
        </script>
    </head>
    <body>
        <div id="container">
            <div id="wrapper">
                <div id="sidebar">
                    <div id="sb_top"><%@ include file="../master/sbTop.jsp"%>
                    </div>
                    
                    <div class="sb_content"><!--##########--> <!-- Start Menu --> <%@ include
         file="../master/menu.jsp"%> <!-- Profile --> <%@ include
         file="../master/profile.jsp"%> <!-- links -->
<%@ include file="../master/links.jsp"%>
                        <div class="copyright"><%@ include file="../master/copyright.jsp"%>
                        </div>
                        
                    </div>
                <!-- /sb_content --></div>
                <!-- /sidebar --> <!-- Top -->
                <div id="header"><%@ include file="../master/header.jsp"%>
                </div>
                
                
                <!-- Start main content -->
                <div id="content">
                    <div id="introduction">
                        <h1>Student Registration - SPMS</h1>
                        <h2>Student Project Managment System</h2>
                    </div>
                    <!-- /intro -->
                    
                    <h1>Student Registration</h1>
                                         <%
                                          if(control.equals("true"))
                                            {
                                         
                                         %>
                    <center>
                        <form name="stReg" action="insertStudent.jsp" method="post" onsubmit="return isCorrect(this)">
                            <table border="0"> 
                                
                                <tr>
                                    <td  class="style1">
                                        <h2>Student Information</h2>
                                    </td>
									<td>
										 <div id='incorrectFields' class='required'></div>
									 </td>
                                </tr>
                                <tr>
                                    <td>
                                        <hr />
                                    </td>
                                    <td>
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* First Name</td>
                                    <td><input type="text" name="fn" size="30" ></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* Middle Name</td>
                                    <td><input type="text" name="mn" size="30" /></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* Last Name</td>
                                    <td><input type="text" name="ln" size="30" /></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* GPA</td>
                                    <td><input type="text" name="GPA" size="30" onblur="value = parseFloat(value);"/></td>
                                </tr>
                                <tr>
                                    <td align="left">Gender</td>
                                    <td align="left"><select name="aff">
                                            <option value="ma">Male</option>
                                            <option value="fm">Female</option>
                                    </select></td>
                                </tr>
                                
                                <tr>
                                    <td align="left">Mobile Phone</td>
                                    <td><input type="text" name="mp" size="30" onblur="value = parseInt(value);"/></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* Email</td>
                                    <td><input type="text" onblur="isEmail(this.value)" name="email" size="30" /></td>
                                </tr>
                                
                                <tr> 
                                    <td class="style1">
                                        <h2>User Account</h2>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <hr />
                                    </td>
                                    <td>
                                        <hr />
                                    </td>
                                </tr>
                                <tr><td class="required" align="left">* Enrollement Key</td><td><input type="text" name="ek" size="30" /></td></tr>
                                <tr>
                                    <td class="required" align="left">* Login<div id='isExist'></div></td> 
                                    <td><input type="text" name="login" size="30" onblur="isExisted(this.value)"/></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* Password</td>
                                    <td><input type="password" name="pwd" size="30" /></td>
                                </tr>
                                <tr>
                                    <td class="required" align="left">* Re-Password</td>
                                    <td><input type="password" name="rpwd" size="30" /></td>
                                </tr>
                                <tr>
                                    <td>
                                        <hr />
                                    </td>
                                    <td>
                                        <hr />
                                    </td>
                                </tr>
                                <tr>
                                    <td><input type="submit" value="Register" /></td>
                                    <td></td>
                                </tr>
                            </table>
                        </form>
                        
                    </center>

               <%
}
else
{
%>
        <br/><br/><center><h2>Registeration is not available</h2></center>
<%}%> 
                </div>
            <!-- /content --></div>
            <!-- /wrapper -->
            <div class="clear">&nbsp;</div>
        <!-- Important! Fix the problem of height in Firefox --></div>
        <!-- /Container -->

        
    </body>
</html>